package com.toymate.mqtt.listener;

import lombok.extern.slf4j.Slf4j;
import net.dreamlu.iot.mqtt.core.server.event.IMqttConnectStatusListener;
import org.springframework.stereotype.Service;
import org.tio.core.ChannelContext;

/**
 * mqtt 连接状态
 *
 * @author weirdor (179946422@qq.com)
 * @version v1.0.0
 */
@Service
@Slf4j
public class MqttConnectStatusListener implements IMqttConnectStatusListener {

    @Override
    public void online(ChannelContext context, String clientId, String username) {
        log.info("Mqtt clientId:{} username:{} online.", clientId, username);
    }

    @Override
    public void offline(ChannelContext context, String clientId, String username, String reason) {
        log.info("Mqtt clientId:{} username:{} offline reason:{}.", clientId, username, reason);
    }
}